home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d11
/
nansi22b.arc
/
SETRAW.LC
< prev
next >
Wrap
Text File
|
1987-12-03
|
2KB
|
73 lines
/*------ setraw.lc ----------------------------------------------
Lattice C routines which get and set the current raw/cooked state
of a file, given its Lattice file descriptor.
Useful when trying to obtain high console output speeds.
----------------------------------------------------------------*/
#include "\lc\dos.h"
#define CARRY 0x1
#define ERROR (-1)
#define TRUE 1
#define FALSE 0
extern _oserr;
/*---- getraw --------------------------------------------------
Returns TRUE if file fd is a device in raw mode; FALSE otherwise.
Returns ERROR, puts errorcode in _oserr, if DOS error.
----------------------------------------------------------------*/
getraw(fd)
int fd;
{
union REGS inregs;
union REGS outregs;
int flags;
if (fd > 2) fd+=2; /* convert to DOS fd */
inregs.x.bx = fd;
inregs.x.ax = 0x4400; /* get file attributes */
flags = intdos(&inregs, &outregs);
if (flags & CARRY) {
_oserr = outregs.x.ax;
return -1;
}
return (outregs.x.dx & 0x20) ? TRUE : FALSE;
}
/*---- setraw --------------------------------------------------
Sets Raw state of file fd to raw_on (if file is not a device, does nothing).
Returns zero if successful.
Returns ERROR & errorcode in _oserr if DOS error.
----------------------------------------------------------------*/
setraw(fd, raw_on)
int fd, raw_on;
{
union REGS inregs;
union REGS outregs;
int flags;
if (fd > 2) fd+=2; /* convert to DOS fd */
inregs.x.ax = 0x4400; /* get file attributes */
inregs.x.bx = fd;
flags = intdos(&inregs, &outregs);
if (flags & CARRY) {
_oserr = outregs.x.ax;
return ERROR;
}
if ((outregs.x.ax & 0x80) == 0) /* return zero if not device */
return 0;
outregs.x.ax = 0x4401; /* set file attributes */
outregs.x.bx = fd;
outregs.x.dx &= 0xcf; /* clear old raw bit & hi byte */
if (raw_on) outregs.x.dx |= 0x20; /* maybe set new raw bit */
flags = intdos(&outregs, &inregs);
if (flags & CARRY) {
_oserr = inregs.x.ax;
return ERROR;
}
return 0;
}
/*-- end of setraw.lc --*/